<?php
namespace App\Http\Resources\Common;

use App\Http\Resources\ResourceCollection;
use App\Services\Utils\TencentYun\ImageService;

class FishKindResource extends ResourceCollection
{

    /**
     * Transform the resource into an array.
     *
     * @param \Illuminate\Http\Request $request            
     * @return array
     */
    public function toArray($request)
    {
        return $this->collection->map(function ($item, $key) {
            $item['img_view'] = ImageService::makeDownloadUri($item['img'], ImageService::BUCKET_TRADE);
            return $item;
        })
            ->groupBy('classify_id')
            ->toArray();
    }
}
